<%@ page import="model.Cart" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="model.Book" %>
<%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2021/12/13
  Time: 22:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" +
                request.getServerPort() + path + "/";
    %>
    <base href="<%=basePath%>">
    <title>sss</title>
    <link rel="stylesheet" href="<%=basePath%>css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
    body{
        margin: 0 10px 0 10px;
        padding: 0;
        height: 100%;
    }
    .form_body{
        display: flex;
        justify-content: flex-start;
        padding: 20px;
    }
    .form_item{
        width: 20%;
    }
    td,th{
        text-align: center;
    }
</style>
<body>
<form  role="form" method="get" action="#">
    <div class="form_body">
        <div class="form_item">图书名称：<input type="text" name="name" id="name" autocomplete="off" required=""></div>
        <button><a href="<%=basePath%>QueryCart">返回</a></button>
    </div>
</form>
<table class="table table-bordered table-hover" style="width: 100%">
    <thead>
    <tr>
        <th>ID</th>
        <th>图书名称</th>
        <th>图书数量</th>
        <th>选中的图书数量</th>
        <th>图书价格</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <% request.setCharacterEncoding("utf-8");%>
    <%
        List<Cart> carts = (ArrayList)request.getAttribute("cart");
        int i = 0;
        for(Cart cart:carts){
    %>
    <tr>
        <td><%=i%></td>
        <td><%=cart.getBk_name()%></td>
        <td><%=cart.getBk_cartNum()%></td>
        <td><%=cart.getBk_cartNum_selected()%></td>
        <td><%=cart.getC_price_selected()%></td>

        <td>
            <button class="btn" data-toggle="modal" data-target="#myModal">修改</button>
        </td>
        <%--                <button><a href="../deleteBook?name=<%=book.getBk_name()%>">删除</a></button></td>--%>
    </tr>
    <%}%>
    </tbody>
</table>
<!-- 修改信息模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="">
                    新增Book
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" action="<%=basePath%>UpdateCartByName" method="get">
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_name"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">购物车总图书数量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_cartNum"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">选中图书数量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_cartNum_selected"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">选中图书价格</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="c_price_selected"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                        </button>
                        <input type="submit" class="btn btn-primary" value="添加" />
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
</html>

